<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>一个简单的canvas实例</title>
    <style>
        body {
            background: #ddd;
        }
        canvas {
            margin: 10px;
            padding:10px;
            background: white;
            border: thin inset #aaa;
            /* width: 600px;
            height: 300px; */
        }
    </style>
</head>
<body>
    <canvas id="c">您的浏览器不支持canvas</canvas>
    <!-- canvas元素有两个宽度数据，分别是：元素本身大小、画布大小 -->
    <!-- css修改的只是元素本身大小，画布大小任然没有变化，就会对画布进行缩放，而失真 -->
<script>
    var c = document.getElementById('c');
    var ctx = c.getContext('2d');
    ctx.font = '38px Arial';
    ctx.fillStyle = 'cornflowerblue';
    ctx.strokeStyle = 'blue';
    ctx.fillText('Hello Canvas', c.width / 2 - 150, c.height / 2 + 15);
    ctx.strokeText('Hello Canvas', c.width / 2 - 150, c.height / 2 + 15);
</script>
</body>
</html>